
def get_breadcrumb(category):

    breadcrumb=dict(
        cat1='',
        cat2='',
        cat3=''
    )

    if category.parent is None:
        #当前类别为一级类别
        breadcrumb['cat1']=category
    elif category.subs.count() == 0:
        #当前类别为三级类别
        breadcrumb['cat3']=category
        cat2=category.parent
        breadcrumb['cat2']=cat2
        breadcrumb['cat1']=cat2.parent
    else:
        #当前类别为二级
        breadcrumb['cat2']=category
        breadcrumb['cat1']=category.parent

    return breadcrumb